﻿using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections.Generic;
using System;

[Serializable]
public class BTNodePropertyView : BTViewBase {

    #region Public Variables

    #endregion

    #region Protected Variables
    GUIStyle labelStyle;
    #endregion

    #region Constructors
    public BTNodePropertyView() : base("Property View") 
    {
        labelStyle = new GUIStyle();
    }

    void OnEnable()
    {
        
        labelStyle.normal.background = null;    //这是设置背景填充的
        labelStyle.normal.textColor = new Color(1, 1, 1);   //设置字体颜色的
        labelStyle.fontSize = 20;
        labelStyle.wordWrap = true;
    }
    #endregion

    #region Main Methods
    public override void UpdateView(Rect editorRect, Rect precentageRect,Event e, BTNodeGraph curGraph)
    {
        base.UpdateView(editorRect,precentageRect,e, curGraph);
        Rect box1 = viewRect;
        box1.height = 100f;
        GUI.Box(box1, viewTitle, viewSkin.GetStyle("ViewBG"));

        //Debug.Log(viewRect);
        GUILayout.BeginArea(viewRect);
        if (curGraph != null)
        {
            GUILayout.Space(40f);

            GUILayout.Label(curGraph.treeDes,labelStyle,GUILayout.Width(viewRect.width));
        }
        GUILayout.Space(40f);
        GUILayout.Box("Node Properties", viewSkin.GetStyle("ViewBG2"));
        if(curGraph != null && curGraph.selectedNode != null)
        {
            GUILayout.Space(20f);
            curGraph.selectedNode.DrawNodeProperties();
        }
        GUILayout.EndArea();

        ProcessEvents(e);
    }

    public override void ProcessEvents(Event e)
    {
        base.ProcessEvents(e);

        if (viewRect.Contains(e.mousePosition))
        {

        }
    }
    #endregion

    #region Utility Methods

    #endregion
}
